import React, { Component } from 'react'

export default class App extends Component {
  state = {
    value: '',
    checked: true
  }
  // handleIptChange = ()=> {
  //   console.log(this.state.value)
  // }
  // handleCheckboxChange = ()=> {
  //   console.log(this.state.checked)
  // }

  render() {
    return (
      <div>
        {/* 只读  不报warning */}
        {/* <input type="text" value={this.state.value} readOnly/> */}
        {/* 将value改成defaultValue 
        表单不受控(state里的值不变，表单能被操作)*/}
        {/* <input type="text" defaultValue={this.state.value} onChange={this.handleIptChange}/>
        <input type="checkbox" defaultChecked={this.state.checked} onChange={this.handleCheckboxChange}/> */}

        {/* undefined或者null时表单能被操作 */}
        <input type="text" value={null}/>
      </div>
    )
  }
}
